﻿namespace DomainServices.Tools
{
    using System;
    using System.CodeDom;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.ServiceModel.DomainServices.Server;

    internal class ComplexTypeProxyGenerator : DataContractProxyGenerator
    {
        private DomainServiceDescription _domainServiceDescription;

        public ComplexTypeProxyGenerator(CodeDomClientCodeGenerator proxyGenerator, Type complexType, DomainServiceDescription domainServiceDescription, IDictionary<Type, CodeTypeDeclaration> typeMapping) : base(proxyGenerator, complexType, typeMapping)
        {
            this._domainServiceDescription = domainServiceDescription;
        }

        protected override void AddBaseTypes(CodeNamespace ns)
        {
            base.ProxyClass.BaseTypes.Add(CodeGenUtilities.GetTypeReference("System.ServiceModel.DomainServices.Client.ComplexObject", ns.Name, false));
        }

        protected override IEnumerable<Type> GetDerivedTypes()
        {
            return Enumerable.Empty<Type>();
        }

        protected override string GetSummaryComment()
        {
            return string.Format(CultureInfo.CurrentCulture, DomainServices.Tools.Resource.CodeGen_Complex_Class_Summary_Comment, new object[] { base.Type.Name });
        }

        protected override IEnumerable<Type> ComplexTypes
        {
            get
            {
                return this._domainServiceDescription.ComplexTypes;
            }
        }

        protected override bool IsDerivedType
        {
            get
            {
                return false;
            }
        }
    }
}

